package org.example.cglib;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * CGLIB代理类
 */
public class CglibProxy implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("开始调用...");
        System.out.println("代理的方法" + method.getName());
        Object result = methodProxy.invokeSuper(o,objects);
        System.out.println("调用完成");
        return result;
    }
}
